#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Sat Nov 13 20:25:04 2021

@author: Aiping
"""

##### UPDATE TABLE #####################



# import sqlite3

# conn = sqlite3.connect('test.db')
# c = conn.cursor()
# print ("Opened database successfully")

# c.execute("UPDATE Company set SALARY = 25000.00 where ID=1")
# conn.commit()
# print ("Total number of rows updated :", conn.total_changes)

# cursor = conn.execute("SELECT id, name, address, salary  from COMPANY")
# for row in cursor:
#    print ("ID = ", row[0])
#    print ("NAME = ", row[1])
#    print ("ADDRESS = ", row[2])
#    print ("SALARY = ", row[3], "\n")

# print ("Operation done successfully")
# conn.close()




##### DELETE TABLE #####################

import sqlite3
conn = sqlite3.connect('test_1.db')

c = conn.cursor()
print('connected to the database successfully')

c.execute("DELETE from company where ID = 2")
conn.commit()
print("Total row of change:", conn.total_changes)

c_data = conn.execute("SELECT id, name, address, salary from company")

for row in c_data:
    print("ID = ", row[0])
    print("NAME = ", row[1])
    print("ADDRESS = ", row[2])
    print("SALARY = ", row[3], '\n')
    
print('operation done successfully')
conn.close()    






